
export default {
  state: {
    pointInfo: {},
    wareList: [],
    wareItemOrigin: undefined,
  },
  getters: {
    findWare1: (state) => id => state.wareList.find((item)=>{
      return item.id.toString() === id.toString();
    }),
    findWare: (state) => id => state.wareList.find((item)=>{
      if(!item){
        return false;
      }
      console.log(item);
      return item.id.toString() === id.toString();
    })
  },
  mutations: {
    setPointInfo(state, pointInfo) {
      state.pointInfo = pointInfo
    },
    setWareList(state, wareList){
      state.wareList = wareList
    }
  },
  actions: {
    async getPointInfo({ commit},{mobilePhone, enterpriseId}) {
      console.log(this, mobilePhone, enterpriseId, 'mobilePhone');
      const res = await this.$Request({
        url: "/getCustomerPointsInfo",
        method: "GET",
        data: {
          mobilePhone,
          enterpriseId,
        }
      });

      if (res.retCode === 0) {
        commit("setPointInfo", res.data);
      }
    },
    getWareList({ commit, state, rootGetters },id) {
      console.log("state",id);
      return this.$axios
        .$get("/getIntegralWaresInfoList", {
          params: {
            stationId: id,
          },
        })
        .then((res) => {
          if (res.retCode == 0) {
            commit("setWareList", res.data)
          }
        });
    },
    getPointsRecordList({ commit, state, rootGetters },params){
      return this.$axios.$get("/getCustomerPointsInfogetCustomerPointsRecordList",{
        params
      })
    }
    
  }
}
